var passport = passport || window.passport || {};
passport._modulePool = passport._modulePool || {};
passport._define = passport._define || function(a, b) {
	passport._modulePool[a] = b && b()
};
passport._getModule = passport._getModule || function(a) {
	return passport._modulePool[a]
};
passport.pop = passport.pop || {};
passport.pop.insertScript = passport.pop.insertScript || function(b, a) {
	var e = document, c = e.createElement("SCRIPT");
	c.type = "text/javascript";
	c.charset = "UTF-8";
	if (c.readyState) {
		c.onreadystatechange = function() {
			if (c.readyState == "loaded" || c.readyState == "complete") {
				c.onreadystatechange = null;
				a && a()
			}
		}
	} else {
		c.onload = function() {
			a && a()
		}
	}
	c.src = b;
	e.getElementsByTagName("head")[0].appendChild(c)
};
passport.pop.init = passport.pop.init || function(f) {
	var h = {
		"http:" : "http://passport.bdimg.com",
		"https:" : "https://passport.baidu.com"
	};
	var b = h[window.location.protocol.toLowerCase()], k = "js", a = {
		uni_login : "/passApi/js/uni_login_beb571ee.js",
		uni_login_tangram : "/passApi/js/uni_login_tangram_4b80a4ab.js"
	}, l = "/passApi/css/uni_login_f74a6ee5.css";
	var f = f || {};
	var g = document, i, f = f || {}, j = "_PassUni" + new Date().getTime();
	var e = b + l;
	if (f.cssUrlWrapper) {
		e = cssUrlWrapper.join("uni_login.css")
	}
	i = {
		show : function() {
			i.loadPass(f.apiOpt);
			i.willShow = true;
			return i
		},
		loadPass : function() {
			var d = g.createElement("link");
			d.rel = "stylesheet";
			d.type = "text/css";
			d.href = e;
			d.disabled = false;
			g.getElementsByTagName("head")[0].appendChild(d);
			i.show = function() {
				i.willShow = true;
				return i
			};
			if (f.plugCss) {
				d = g.createElement("link");
				d.rel = "stylesheet";
				d.type = "text/css";
				d.href = f.plugCss;
				d.disabled = false;
				g.getElementsByTagName("head")[0].appendChild(d)
			}
			i.passCallback();
			delete i.loadPass
		},
		passCallback : function() {
			if (i.components.length > 0) {
				passport.pop.insertScript(i.components.shift(), i.passCallback)
			} else {
				passport.pop.Login(f, i, function() {
							if (i.willShow) {
								i.show()
							}
						});
				delete i.passCallback;
				delete i.components
			}
		},
		components : []
	};
	var c = "uni_login";
	if (f.tangram) {
		c += "_tangram"
	}
	if (f.authsite instanceof Array) {
		i.components.push("http://passport.baidu.com/phoenix/account/jsapi")
	}
	i.components.push(b + a[c]);
	if (f.cache) {
		i.loadPass(f.apiOpt)
	}
	if (f.id) {
		if (g.getElementById(f.id)) {
			g.getElementById(f.id).onclick = function() {
				i.show()
			}
		}
	}
	return i
};